﻿Public Class Frm1ItemMenu_RMP

    Public Sub cargarRegistros(ByVal fila As Integer)
        Try
            Dim accion As New ItemsDAO
            'Llenar tabla
            Dim tabla As New DataTable
            tabla = accion.mostrar
            'Comprobar si hay datos
            If Not tabla Is Nothing Then
                'Cargar datos en el grid
                'DGV1.DataSource = tabla
                FormatosGrid.funciones.formatoGrid_Items(DGV1, tabla)
                'Mostrar datos en los controles
                txtId.Text = DGV1.Rows(fila).Cells(0).Value
                txtNombre.Text = DGV1.Rows(fila).Cells(1).Value
                txtOrigen.Text = DGV1.Rows(fila).Cells(2).Value
                txtPresentacion.Text = DGV1.Rows(fila).Cells(3).Value
                txtPeso.Text = DGV1.Rows(fila).Cells(4).Value
                txtTalla.Text = DGV1.Rows(fila).Cells(5).Value
                txtCosto.Text = DGV1.Rows(fila).Cells(6).Value
                txtTipo.Text = DGV1.Rows(fila).Cells(7).Value
                lblIDtipo.Text = DGV1.Rows(fila).Cells(8).Value
                'Seleccionar toda la fila
                DGV1.Rows(fila).Selected = True
                DGV1.CurrentCell = DGV1.Rows(fila).Cells(1)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK,
                        MessageBoxIcon.Warning)
        End Try
    End Sub



    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellContentClick

    End Sub



    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim frmitenbuscar As New Frm1ItemBuscar
        frmitenbuscar.Show()

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.Close()

    End Sub

    Private Sub Frm1ItemMenu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cargarRegistros(0)
        txtId.Enabled = False
        txtNombre.Enabled = False
        txtOrigen.Enabled = False
        txtPresentacion.Enabled = False
        txtPeso.Enabled = False
        txtTalla.Enabled = False
        txtCosto.Enabled = False
        txtTipo.Enabled = False

    End Sub
    Private Sub dgv1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DGV1.CurrentCellChanged
        Try
            If Not DGV1.CurrentCell Is Nothing Then
                With DGV1
                    txtId.Text = .Rows(.CurrentCell.RowIndex).Cells(0).Value
                    txtNombre.Text = .Rows(.CurrentCell.RowIndex).Cells(1).Value
                    txtOrigen.Text = .Rows(.CurrentCell.RowIndex).Cells(2).Value
                    txtPresentacion.Text = .Rows(.CurrentCell.RowIndex).Cells(3).Value
                    txtPeso.Text = .Rows(.CurrentCell.RowIndex).Cells(4).Value
                    txtTalla.Text = .Rows(.CurrentCell.RowIndex).Cells(5).Value
                    txtCosto.Text = .Rows(.CurrentCell.RowIndex).Cells(6).Value
                    txtTipo.Text = .Rows(.CurrentCell.RowIndex).Cells(7).Value
                    lblIDtipo.Text = .Rows(.CurrentCell.RowIndex).Cells(8).Value
                End With
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK,
              MessageBoxIcon.Warning)
        End Try
    End Sub


End Class